<template>
  <el-card shadow="never">
    <div slot="header">
      <el-button @click="$router.push({name: 'assetsNewCheckAudit'})">返回</el-button>
    </div>
    <el-tabs v-model="name" @tab-click="handleTabClick">
      <el-tab-pane label="正常未审核" name="normal"></el-tab-pane>
      <el-tab-pane label="状态改变未审核" name="change"></el-tab-pane>
      <el-tab-pane label="已审核" name="have"></el-tab-pane>
    </el-tabs>
    <check-table ref="checkTable" />
  </el-card>
</template>

<script>
import CheckTable from './CheckTable'
import { getSession, setSession, removeSession } from '@/utils/util'

export default {
  components: {
    CheckTable
  },
  data() {
    return {
      name: 'normal',
      row: this.$route.params.obj || getSession('auditDetailRow')
    }
  },
  mounted() {
    this.$refs.checkTable.setName(this.name)
  },
  created() {
    if (!this.row) {
      this.$message.error('页面发生错误，即将返回列表页')
      setTimeout(() => {
        this.$router.push({
          name: 'assetsNewCheckAudit'
        })
      }, 1000)
    } else {
      setSession('auditDetailRow', this.row)
    }
  },
  methods: {
    handleTabClick(tab, event) {
      this.$refs.checkTable.setName(this.name)
    }
  },
  destroyed() {
    removeSession('auditDetailRow')
  }
}
</script>
